<style lang="scss" scoped>
	.nav {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		background-color: #f5f5f5;
		z-index: 10;
	}

	.top {
		// padding: 20rpx 0;
		width: 100%;
	}

	.search {
		width: 690rpx;
		height: 68rpx;
		background: #f4f5f7;
		border: 2rpx solid #f5f5f5;
		border-radius: 46rpx;
		margin: 0rpx auto;
		padding: 20rpx;

		.ipt {
			flex: 1;
		}
	}

	.tab {
		margin-top: 20rpx;
		padding: 0 20rpx;
		height: 100rpx;
		border-bottom: 1px solid #ccc;

		.actived {
			color: #409EFF;
		}
	}

	.lists {
		// margin-top: 228rpx;
		margin-top: 110rpx;
		.list {
			height: 100rpx;
			padding: 20rpx;
		}

		.actived {
			color: #409EFF;
		}
	}
	.footer{
		width:100%;
		background-color: white;
		position: fixed;
		bottom:0;
		left:0;
		border-top: 1px solid #cccccc;
	}
</style>
<template>
	<view class="content">
		<view class="nav">
			
			<view class="tab align-flex bgwhite">
				<view class="gray m-right20">已选系统</view>
				<view style="max-width: 550rpx;" class="textColor one" @click="change(index)"> <span v-for="item,index in choose" :key="index"
						class="actived">{{item.name}}<span v-if="index<choose.length-1"
							class="p-left10 p-right10">/</span></span> </view>
			</view>
		</view>
		<view class="lists bgwhite">
			<view class="list between-flex f28" v-for="item,index in list" :key="index"
				@click="chooseItem(item,index)">
				<view class="textColor" :class="index==chooseIndex?'actived':''">{{item.name}}</view>
				
				<view v-if="item.checked">
					<u-icon color="#409EFF" name="checkbox-mark"></u-icon>
				</view>
			</view>
			
		</view>
		<view class="space"></view>
		<view class="footer center-flex paddingBottom">
			<view class="lbtn" @click="confirm">确定</view>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				
				list: [], //显示的列表
				choose:[]
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			//点击最后一级时触发该事件
			confirm() {
				console.log(this.choose)
				var list = this.choose
			
				var name = [],
					value = []
				list.forEach(item => {
					name.push(item.name)
					value.push(item.value)
			
				})
			
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
			
				if (prevPage.$vm.hasOwnProperty('aboutSystem')) {
			
					prevPage.$vm.aboutSystem = {
						name: name.join('/'),
						value:value.join(','),
						id:value.join(',')
					}
				}
				uni.$emit('chooseSys',{
						name: name.join('/'),
						value:value.join(','),
						id:value.join(',')
					})
				uni.navigateBack({
			
				})
			},
			chooseItem(item, index) {
				
				if(item.checked){
					this.list[index].checked=false
					if(this.choose.indexOf(item)!=-1){
						var index=this.choose.indexOf(item)
						this.choose.splice(index,1)
					}
					
				}else{
					this.list[index].checked=true
					if(this.choose.indexOf(item)==-1){
						this.choose.unshift(item)
					}
				}
				this.$forceUpdate()
			},
			
			
			getlist() {
				
				var list = uni.getStorageSync('dic').aboutSystem
				this.list=list
			},
			

		}
	}
</script>
